//
//  WYHomeCollectionCell.m
//  CirclePush
//
//  Created by admin on 2018/4/9.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYHomeCollectionCell.h"
#import "WYHomeCategoryCell.h"
@interface WYHomeCollectionCell()<UICollectionViewDataSource>

@property (nonatomic,strong)NSArray *imageArray;
@property (nonatomic,strong)NSArray *nameArray;
@property (nonatomic,strong)NSArray *dataArray;
@end

@implementation WYHomeCollectionCell

-(NSArray *)imageArray
{
    if (!_imageArray) {
        _imageArray = @[@"icon_outdoors",@"iocn_television",@"icon_newMedia",@"icon_Print",@"icon_ Radio",@"icon_ video",@"icon_network",@"icon_Magazine",@"icon_ device",@"iocn_home_more"];
    }
    return _imageArray;
}
-(NSArray *)nameArray
{
    if (!_nameArray) {
        _nameArray = @[@"户外",@"电视",@"新媒体",@"纸媒",@"广播",@"视频",@"网络",@"杂志",@"设备",@"更多"];
    }
    return _nameArray;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.dataArray = [WYMediaType getMediaLsit];
    [self setupUI];
    // Initialization code
}
-(void)setupUI
{
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
    layout.itemSize=CGSizeMake((kScreenWidth-50)/5, kScreenWidth/5);
    //横向最小距离
    layout.minimumInteritemSpacing=1.0f;
    layout.minimumLineSpacing=1.0f;
    //cell距离上  左  下 右 的距离
    layout.sectionInset=UIEdgeInsetsMake(20, 5, 0, 5);
    [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
    [self.collectionView setCollectionViewLayout:layout];
    [self.collectionView registerNib:[UINib nibWithNibName:@"WYHomeCategoryCell" bundle:nil] forCellWithReuseIdentifier:@"WYHomeCategoryCell"];
    self.collectionView.dataSource = self;
    
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    WYHomeCategoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WYHomeCategoryCell" forIndexPath:indexPath];
    
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"WYHomeCategoryCell" owner:nil options:nil].firstObject;
    }
    WYMediaType *type = self.dataArray[indexPath.row];
    cell.nameLabel.text = type.mediaTypeName;
    cell.cateImageView.image =[UIImage imageNamed:type.image];
//    cell.nameLabel.text = self.nameArray[indexPath.row];
//    cell.cateImageView.image =[UIImage imageNamed:self.imageArray[indexPath.row]];
    return cell;
}








@end
